<template>

	<view class="DetailView">
		<view class="content">
			<z-paging ref="paging" :refresher-only="true" :fixed="true" :show-loading-more-no-more-view='false'
				:refresher-enabled="false" :refresher-threshold="0" hide-refresher-when-reload
				hide-refresher-when-enabled>
				<template #top>
					<m-drag-button :style="{ opacity: BtnShow ? 1 : 0, }" :isDock="true" :existTabBar="true"
						:initialBottom="160" @btnClick="scan">
						<template #BtnContent>
							<u-icon name="scan" color="#fff" size="54rpx"></u-icon>
						</template>
					</m-drag-button>
					<u-navbar :fixed="false" title="模具维修" :autoBack="true" :safeAreaInsetTop="true"
						@leftClick='leftClick' leftIconColor="#fff"></u-navbar>
				</template>
				<view class="MainBox">
					<u--form labelPosition="left" :model="baseFormData" :rules="rules" ref="uForm">
						<u-cell icon="list-dot" :title="EnableApplyForShow?'申请人填写':'基本信息'"
							style='background-color: #eee;'></u-cell>
						<u-form-item labelWidth="100" label="模具" borderBottom leftIcon="file-text" required
							prop='MoludName' :leftIconStyle="{'font-size':'20px'}"
							@click="openBaseScreen('模具','radio')">
							<u--input v-model="baseFormData.MoludName" placeholder="请选择模具" readonly
								border="none"></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
						</u-form-item>
						<u-form-item labelWidth="100" label="申请人" borderBottom leftIcon="order"
							v-show="EnableApplyForShow" :leftIconStyle="{'font-size':'20px'}">
							<u--input v-model="baseFormData.ApplyForMan" placeholder="自动生成" readonly
								border="none"></u--input>
						</u-form-item>
						<u-form-item labelWidth="100" label="申请时间" borderBottom leftIcon="calendar"
							v-show='EnableApplyForShow' :leftIconStyle="{'font-size':'20px'}">
							<u--input v-model="baseFormData.ApplyForTime" placeholder="自动生成" readonly
								border="none"></u--input>
						</u-form-item>
						<u-form-item labelWidth="100" label="故障描述" leftIcon="file-text" required prop="BXContent"
							:leftIconStyle="{'font-size':'20px'}">
							<u--textarea v-model="baseFormData.BXContent" placeholder="请输入故障描述" border="none" autoHeight
								:style="{backgroundColor:'#fff'}" style="padding: 0;"
								:disabled="!buttonShow||buttonTitle == '结束维修'"></u--textarea>
						</u-form-item>
						<u-cell icon="list-dot" title="维修人填写" style='background-color: #eee;'
							v-show="buttonTitle!='保存'"></u-cell>
						<u-form-item labelWidth="100" label="维修编号" borderBottom leftIcon="order"
							v-show="buttonTitle!='保存'" :leftIconStyle="{'font-size':'20px'}">
							<u--input v-model="baseFormData.BillNO" placeholder="自动生成" readonly
								border="none"></u--input>
						</u-form-item>
						<u-form-item labelWidth="100" label="维修人" borderBottom leftIcon="file-text"
							v-show="buttonTitle!='保存'" :prop="buttonTitle == '开始维修'?'MaintainMan':''" required
							:leftIconStyle="{'font-size':'20px'}" @click="openBaseScreen('维修人员','radio')">
							<u--input v-model="baseFormData.MaintainMan" placeholder="请选择人员" readonly border="none"
								required></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
						</u-form-item>

						<u-form-item labelWidth="100" label="维修内容" borderBottom leftIcon="file-text" required
							v-show="buttonTitle!='保存'" :prop="buttonTitle == '开始维修'?'GZCause':''"
							:leftIconStyle="{'font-size':'20px'}">
							<u--textarea v-model="baseFormData.GZCause" placeholder="请输入维修内容" border="none" autoHeight
								:style="{backgroundColor:!buttonShow?'#fff':''}" style="padding: 0;"
								:disabled="!buttonShow"></u--textarea>
						</u-form-item>
						<u-form-item labelWidth="100" label="维修方式" borderBottom leftIcon="file-text"
							v-show="buttonTitle!='保存'" :prop="buttonTitle == '开始维修'?'WayName':''" required
							:leftIconStyle="{'font-size':'20px'}" @click="addWay('WXFS')">
							<u--input v-model="baseFormData.WayName" placeholder="请选择维修方式" border="none"
								readonly></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
						</u-form-item>
						<u-form-item labelWidth="100" label="维修费用" borderBottom leftIcon="coupon"
							v-show="buttonTitle!='保存'" :prop="buttonTitle == '结束维修'?'Cost':''"
							:required='buttonTitle == "结束维修"||buttonTitle == "完成"'
							:leftIconStyle="{'font-size':'20px','color':buttonTitle == '开始维修'?'#999999':'#000'}">
							<u--input v-model="baseFormData.Cost"
								:placeholder="buttonTitle == '结束维修' ?'请输入维修费用':'请在结束时填写'" type='number' border="none"
								:readonly="!buttonShow|| buttonTitle == '开始维修'"></u--input>
						</u-form-item>

						<u-form-item labelWidth="100" label="维修状态" borderBottom leftIcon="order"
							v-show="buttonTitle!='保存'" :leftIconStyle="{'font-size':'20px'}">
							<u--input v-model="baseFormData.MaintenanceStatusName" placeholder="自动带出维修状态" border="none"
								readonly></u--input>

						</u-form-item>

						<u-form-item labelWidth="100" label="维修结果" borderBottom leftIcon="file-text"
							v-show="buttonTitle!='保存'" :prop="buttonTitle == '结束维修'?'FResultName':''"
							:required='buttonTitle == "结束维修"||buttonTitle == "完成"'
							:leftIconStyle="{'font-size':'20px','color':buttonTitle == '开始维修'?'#999999':'#000'}"
							@click="addWay1('SBWX')">
							<u--input v-model="baseFormData.FResultName"
								:placeholder="buttonTitle == '结束维修' ?'请选择维修结果':'请在结束时填写'" border="none"
								readonly></u--input>
							<u-icon slot="right" name="arrow-right"></u-icon>
						</u-form-item>
						<u-form-item labelWidth="100" label="开始时间" borderBottom leftIcon="calendar"
							v-show="buttonTitle!='保存'" :leftIconStyle="{'font-size':'20px'}">
							<u--input v-model="baseFormData.BeginTime" placeholder="自动带出开始时间" readonly
								border="none"></u--input>
						</u-form-item>
						<u-form-item labelWidth="100" label="结束时间" leftIcon="calendar" v-show="buttonTitle!='保存'"
							:leftIconStyle="{'font-size':'20px'}">
							<u--input v-model="baseFormData.WCTime" placeholder="自动带出结束时间" readonly
								border="none"></u--input>
						</u-form-item>
					</u--form>

				</view>
				<template #bottom>
					<view class="BottomBox" :style="$utils.disposeSafeBottomFun()"
						v-show="!baseFormData.MaintainMouldID">
						<button block @click="submit('保存','新增')" style="width: 90%;margin: 0 auto !important;"
							class="content_bottom_primary_Btn">
							保存
						</button>
					</view>
					<view class="BottomBox safe_buttom" :style="$utils.disposeSafeBottomFun()"
						v-show="baseFormData.MaintainMouldID&&buttonShow">
						<button v-if="buttonNum==0" class="CancelBtn" @click="submit('保存','修改')">保存</button>
						<button v-if="buttonTitleNum==1&&ApproveBack('发起申请')" class="ComfirmBtn"
							@click='SubmitBtn(11,"发起申请")'>发起申请</button>
						<button v-if="buttonTitleNum==2&&ApproveBack('撤回申请')" class="ComfirmBtn"
							@click='SubmitBtn(12,"撤回申请")'>撤回申请</button>
						<button v-if="buttonTitleNum==2&&ApproveBack('通过申请')" class="ComfirmBtn"
							@click='SubmitBtn(13,"通过申请")'>通过申请</button>
						<button v-if="buttonTitleNum==2&&ApproveBack('拒绝申请')" class="ComfirmBtn"
							@click='SubmitBtn(14,"拒绝申请")'>拒绝申请</button>
						<button v-if="buttonTitleNum==3&&ApproveBack('开始维修')" class="ComfirmBtn"
							@click='SubmitBtn(21,"开始维修")'>开始维修</button>
						<button v-if="buttonTitleNum==4&&ApproveBack('结束维修')" class="ComfirmBtn"
							@click='SubmitBtn(23,"结束维修")'>结束维修</button>

					</view>

				</template>
			</z-paging>


		</view>
		<u-toast ref="uToast"></u-toast>

		<u-action-sheet :actions="StateList" :show="StateShow" @select="StateClick"
			@close="StateShow=false"></u-action-sheet>
		<m-pda-scancode v-if="$utils.isPda()" listenName="BatchEditScan"
			:SetContent="{action:$store.state.systemConfig.sysDeviceInfo.broadcastAction,extra:$store.state.systemConfig.sysDeviceInfo.broadcastResult}"></m-pda-scancode>

	</view>


</template>

<script>
	import {
		formatDateTime,
		getTimeStamp,
		getFormatDateTime,
		getBefore7DateTime
	} from '@/st_mold/common/base.js';
	import BaseMixin from '@/st_mold/common/base.js';
	export default {
		mixins: [BaseMixin],
		data() {
			return {
				rules: {

					'MoludName': {
						type: 'string',
						required: true,
						message: '模具不能为空',
						trigger: ['change']
					},
					'BXContent': {
						type: 'string',
						required: true,
						message: '故障描述不能为空',
						trigger: ['change']
					},
					'MaintainMan': {
						type: 'string',
						required: true,
						message: '人员不能为空',
						trigger: ['change']
					},
					'GZCause': {
						type: 'string',
						required: true,
						message: '维修内容不能为空',
						trigger: ['blur', 'change']
					},
					'WayName': {
						type: 'string',
						required: true,
						message: '维修方式不能为空',
						trigger: ['change']
					},
					'Cost': {
						type: 'number',
						required: true,
						message: '维修费用不能为空',
						trigger: ['blur', 'change']
					},
					'FResultName': {
						type: 'string',
						required: true,
						message: '维修结果不能为空',
						trigger: ['change']
					}
				},

				baseFormData: {
					MoludID: null,
					MoludName: '',
					MaintainMouldID: 0,
					ApplyForMan: '',
					ApplyForManID: null,
					ApplyForTime: '',
					BXContent: '',
					BillNO: '',
					MaintainMan: '',
					GZCause: '',
					Way: null,
					WayName: '',
					Cost: '',
					WCStatus: '',
					FResult: 0,
					FResultName: '',
					BeginTime: '',
					WCTime: '',
					ApplyForTime: '',
					ProcessNode: null,
					MaintenanceStatus: null,
					MaintenanceStatusName: '',
					FType: 'MJWX'

				},


				buttonShow: true, //按钮是否隐藏
				buttonTitle: '保存', //按钮名称
				buttonNum: 0, //保存按钮值 等于0的时候显示
				buttonTitleNum: 0, //判断审核按钮值
				// tableData: [], //子表数组
				StateShow: false, //维修方式和维修结果 筛选显示
				StateList: [], //维修方式和维修结果数组


				BtnApprove: [], //权限判断
				MJWXSList: [], //维修状态列表
				SBWXList: [], //维修结果列表
				WXFSList: [], //维修方法列表
				MJZTList: [], //模具状态列表

				EnableApplyForShow: true, //判断详情页面EnableApplyFor是否等于1
				EnableApplyForNum: null, //EnableApplyFor值
				BtnShow: false,
			};
		},
		onLoad(item) {
			var that = this
			that.initData()

			let foundNode = null;

			for (const module of this.$store.state.appConfigInfo.ModuleInfo_All) {
				if (module.TreeTypeName === '模具管理') {
					for (const node of module.Node) {
						if (node.APFunName === '模具维修') {
							foundNode = JSON.parse(JSON.stringify(node));
							break; // 找到后立即退出内层循环  
						}
					}
					if (foundNode) {
						break;
					}
				}
			}

			this.BtnApprove = foundNode['IconApprove'];


			// 判断有没有主键ID
			if (item.MaintainMouldID) {
				that.queryList(item.MaintainMouldID)
			} else {
				if (item.item) {
					var item = JSON.parse(item.item)
					this.baseFormData = item
					this.baseFormData.BXContent = this.baseFormData.BXContent = item.FaultName + ':' + item.GZContent
				}

				this.baseFormData.ApplyForManID = this.baseFormData.ApplyForManID ? this.baseFormData.ApplyForManID : this
					.$store.state.UserInfo.EmplID


			}
		},
		onBackPress(options) { // 监听页面返回
			if (options.from == 'navigateBack') { // 通过点击路由返回
				return false;
			} else if (options.from == 'backbutton') { // 通过外置返回
				return true;
			}
		},
		onUnload() { // 监听页面卸载,
			// 关闭监听器
			uni.$off('BatchEditScan');
			uni.$off('devicerepairDetail_Choice');

		},
		mounted() {
			var that = this;

			setTimeout(() => {
				that.BtnShow = true;
			}, 300)
			// PDA扫码处理
			uni.$on('BatchEditScan', function(content) {
				let scanData = that.$utils.wmsFun.scanTransf(content);
				that.scanHandler(scanData);
			})
			uni.$on('devicerepairDetail_Choice', function(ret) {
				console.log(JSON.stringify(ret))
				if (ret.type == '维修人员') {
					that.baseFormData.MaintainMan = ret.data.EmplName
					that.$refs.uForm.validateField('MaintainMan');
				} else if (ret.type == '模具') {
					that.baseFormData.MoludID = ret.data.MoludID
					that.baseFormData.MoludName = ret.data.MoludSelect
					that.$refs.uForm.validateField('MoludName');
				}


			});
		},
		onShow() {

		},
		computed: {


		},
		methods: {
			// pda扫码
			scanHandler(scanData) {
				let that = this;
				if (that.buttonShow) {
					that.MoludChange(scanData.recode, 'pda')
				}

			},
			// 手机扫描
			scan() {
				let that = this;
				if (that.buttonShow) {
					this.$scanPopup.openScan({
						success: function(res) {

							that.MoludChange(res.result, 'phone')
						},
						fail: function(fail) {
							console.log(fail);
						}
					})
				}


			},
			// 处理扫码数据
			MoludChange(res, name) {
				let that = this;
				if (that.buttonShow) {
					let parts = res.split("|");
					var id = parts[1]
					var obj = {

					}
					if (parts[0] == 'MJ') {
						obj.MoludID = id

					} else if (parts[0] == 'MJKW') {
						obj.FStorageID = id
					}
					console.log(obj);
					that.Request.request('MJ_MoludList', obj, (ret) => {
						console.log(ret);
						if (ret.data.ds1[0].status == 500) {
							uni.$u.toast(ret.data.ds1[0].msg)
						} else {
							ret.data.ds.map(obj => {
								obj.WarningStatus = obj.WarningStatus ? obj.WarningStatus : 0
								obj.WarningStatusName = obj.WarningStatusName ? obj.WarningStatusName : ''
								obj.StockDeID = obj.StockDeID ? obj.StockDeID : 0
							})
							that.baseFormData.MoludID = ret.data.ds[0].MoludID
							that.baseFormData.MoludName = ret.data.ds[0].MoludSelect
							that.$refs.uForm.validateField('MoludName');
							that.$forceUpdate()
						}
					})
				}

			},

			async initData() {
				// 加载公共字典数据
				await this.loadCommonDictionaries([{
						type: 'ALL', //模具状态
						key: 'MJZTList'
					},
					{
						type: 'MJWXS', //维修状态
						key: 'MJWXSList'
					},
					{
						type: 'SBWX', //  维修结果列表		
						key: 'SBWXList'
					},
					{
						type: 'WXFS', //  维修方法列表
						key: 'WXFSList'
					}
				]);
			},

			ApproveBack(str) {
				let that = this;
				let Type = false;
				if (that.BtnApprove.length) {
					Type = that.BtnApprove.some(item => {
						return item.MenuName == str
					})
				}
				return Type;
			},

			// 弹框取消
			confirmClick() {
				this.popup_logout = false
			},
			// 判断按钮显示条件
			addPeriodTypeClick() {
				var that = this
				if (that.EnableApplyForNum == 1) {
					if (that.baseFormData.ProcessNode != 2) {
						if (that.baseFormData.ProcessNode == 1 && that.baseFormData.MaintenanceStatus == 0) {
							that.buttonNum = 0 //按钮显示
							that.buttonTitle = '开始维修'
							that.buttonTitleNum = 3 //开始维修按钮显示

						} else if (that.baseFormData.ProcessNode == 1 && that.baseFormData.MaintenanceStatus == 1) {
							that.buttonNum = null
							that.buttonTitle = '结束维修'
							that.buttonTitleNum = 4 //结束维修按钮显示

						}

					} else {
						that.buttonTitle = '完成'
						that.buttonTitleNum = null //隐藏
						that.buttonNum = null
						that.buttonShow = false //按钮隐藏
					}

				} else {

					if (that.baseFormData.ProcessNode == 0 && that.baseFormData.ApplyStatus == 0 && !that.baseFormData
						.MaintainMouldID) {
						that.buttonNum = 0 //保存
					} else if (that.baseFormData.ProcessNode == 0 && that.baseFormData.ApplyStatus == 0 && that
						.baseFormData.MaintainMouldID) {
						that.buttonNum = 0 //保存
						that.buttonTitleNum = 1 //发起申请
					} else if (that.baseFormData.ProcessNode == 0 && that.baseFormData.ApplyStatus == 1) {
						that.buttonNum = null //保存隐藏
						that.buttonTitleNum = 2 //撤回
					} else if (that.baseFormData.ProcessNode == 1 && that.baseFormData.MaintenanceStatus == 0) {
						that.buttonNum = null //保存隐藏
						that.buttonTitle = '开始维修'
						that.buttonTitleNum = 3 //开始维修按钮显示

					} else if (that.baseFormData.ProcessNode == 1 && that.baseFormData.MaintenanceStatus == 1) {
						that.buttonNum = null //保存隐藏
						that.buttonTitle = '结束维修'
						that.buttonTitleNum = 4 //结束维修按钮显示

					} else {
						that.buttonNum = null
						that.buttonTitleNum = null //隐藏
						that.buttonTitle = '完成'
						that.buttonShow = false
					}
				}


				that.$forceUpdate()
			},
			// // 子表删除
			// trash(index) {
			// 	var that = this
			// 	if (that.buttonShow) {
			// 		that.tableData.splice(index, 1)
			// 		this.$forceUpdate()
			// 	}

			// },

			// 维修方法 维修结果
			StateClick(e) {
				var that = this;

				if (that.StateName == 'SBWX') {

					that.baseFormData.FResult = e.id
					that.baseFormData.FResultName = e.name
					that.$refs.uForm.validateField('FResultName'); // 手动触发 MaintainMan 字段的验证
					that.$forceUpdate()
				} else {

					that.baseFormData.WayName = e.name
					that.baseFormData.Way = e.id
					console.log(that.baseFormData.Way);
					that.$refs.uForm.validateField('WayName'); // 手动触发 MaintainMan 字段的验证
					that.$forceUpdate()
				}
				this.$forceUpdate()


			},

			//维修方法
			addWay(str) {
				var that = this;
				if (that.buttonShow) {
					that.StateName = str
					that.StateList = that.WXFSList
					this.StateShow = true
				}
			},
			// 维修结果
			addWay1(str) {
				var that = this;
				if (that.buttonTitle == '结束维修' && that.buttonShow) {
					that.StateName = str

					that.StateList = that.SBWXList
					this.StateShow = true
				}
			},

			addCost() {
				var that = this;
				if (that.buttonTitle == '开始维修') {
					uni.showToast({
						title: '请在结束时填写',
						icon: 'error',
						duration: 2000
					})
				}
			},


			openBaseScreen(str, type) { // 前往筛选页
				let that = this;
				let obj = null;
				let show = true
				let url = '/commonPage/Tool/baseScreen';
				if (that.buttonShow) {
					if (str == '维修人员') {
						obj = {
							allowClear: false,
							cmd: 'MJ_RYSet',
							type: str,
							ListeningName: 'devicerepairDetail_Choice',
							serverSearch: {
								isPaging: false, //是否分页
								searchKey: 'EmplName', //搜索关键词，应包含在param中
								showText: 'EmplName', //查询结果显示的字段
								pageIndexStr: 'PageIndex', //分页页码字段，应包含在param中
								ChoiceDataKey: 'EmplName',
								ChoiceDataData: that.baseFormData.MaintainMan,
							},
							param: {
								EmplName: '',
								PageIndex: 1,
								PageSize: 30
							}
						}

					} else if (str == '模具') {
						if (that.buttonTitle == '结束维修') {
							show = false
						}
						obj = {
							allowClear: false,
							cmd: 'MJ_MoludList',
							type: str,
							ListeningName: 'devicerepairDetail_Choice',
							serverSearch: {
								isPaging: false, //是否分页
								searchKey: 'MoludSelect', //搜索关键词，应包含在param中
								showText: 'MoludSelect', //查询结果显示的字段
								pageIndexStr: 'PageIndex', //分页页码字段，应包含在param中
								ChoiceDataKey: 'MoludID',
								ChoiceDataData: that.baseFormData.MoludID,
							},
							param: {
								FType: 'MJWX',
								MoludSelect: '',
								PageIndex: 1,
								PageSize: 30,
								IsInStorage: -1
							}
						}
					}

					if (show) {
						this.$store.commit('ChangeAndSetStateData', {
							Name1: 'BaseScreenParm',
							data: obj
						})
						uni.navigateTo({
							url: url
						})
					}

				}
			},
			// 提交按钮
			SubmitBtn(num, str) {
				let that = this;

				this.$refs.uForm.validate().then(res => {
					let obj = {
						EmplID: that.baseFormData.ApplyForManID || that.$store.state.UserInfo.EmplID,
						MaintainMan: that.baseFormData.MaintainMan ? that.baseFormData.MaintainMan : '',
						Motion: num,
						MaintainMouldID: that.baseFormData.MaintainMouldID ? that.baseFormData
							.MaintainMouldID : 0,
						ApplyForMan: that.baseFormData.ApplyForMan,
						GZCause: that.baseFormData.GZCause ? that.baseFormData.GZCause : 0,
						FResult: that.baseFormData.FResult ? that.baseFormData.FResult : 0,
						Way: that.baseFormData.Way,
						Cost: that.baseFormData.Cost ? that.baseFormData.Cost : 0,

					};
					console.log(obj)
					that.Request.request('MJ_WXSubmitNode', obj, function(ret) {
						console.log(ret)
						var MaintainMouldID = ret.data.ds[0].MaintainMouldID ? ret.data.ds[0]
							.MaintainMouldID : that
							.baseFormData.MaintainMouldID
						if (ret.data.ds[0].status == 500) {
							uni.$u.toast(ret.data.ds[0].msg)

						} else {
							that.$refs.uToast.show({
								title: '保存',
								type: 'success',
								message: str + '成功'
							})
							that.queryList(MaintainMouldID);
						}
					}, function(err) {
						console.log(err)
					})
				}).catch(errors => {
					console.log(JSON.stringify(errors))
					if (Array.isArray(errors)) {
						uni.$u.toast('请完善表单')
					}
				});


			},
			// 保存
			submit(str, name) {
				var that = this;

				var that = this;

				// 1. 备份原始规则
				const originalRules = {
					...that.rules
				};

				// 2. 临时创建新规则对象 (只保留MoludName和BXContent)
				const tempRules = {
					'MoludName': originalRules.MoludName,
					'BXContent': originalRules.BXContent
				};

				// 3. 临时替换表单规则
				that.rules = tempRules;

				// 4. 执行验证
				this.$refs.uForm.validate().then(res => {

					if (![0, 1].includes(that.baseFormData.Way)) {
						that.baseFormData.Way = null;
					}

					// 5. 验证通过后恢复原始规则
					that.rules = originalRules;
					let obj = {
						BXContent: that.baseFormData.BXContent,
						MaintainMouldID: that.baseFormData.MaintainMouldID,
						BillDate: that.baseFormData.ApplyForTime,
						MoludID: that.baseFormData.MoludID,
						GZCause: that.baseFormData.GZCause ? that.baseFormData.GZCause : '',
						Way: that.baseFormData.Way,
						MaintainMan: that.baseFormData.MaintainMan ? that.baseFormData.MaintainMan : '',
					};
					console.log(obj)
					that.Request.request('MJ_WXSubmit', obj, function(ret) {
						console.log(ret)
						var MaintainMouldID = ret.data.ds[0].MaintainMouldID
						if (ret.data.ds[0].status == 500) {
							uni.$u.toast(ret.data.ds[0].msg)
						} else {
							that.$refs.uToast.show({
								title: '保存',
								type: 'success',
								message: '保存成功'
							})
							that.queryList(MaintainMouldID);
						}
					}, function(err) {
						console.log(err)
					})
				}).catch(errors => {

					that.rules = originalRules;
					console.log(JSON.stringify(errors))
					if (Array.isArray(errors)) {
						uni.$u.toast(errors[0].message)
					}
				});

			},

			// 详情数据
			queryList(id) {
				var that = this
				try {
					var obj = {
						PageIndex: 1,
						PageSize: 30,
						FBDate: getBefore7DateTime(),
						FEDate: getFormatDateTime(new Date()),
						MaintenanceStatus: -1,
						MaintainMouldID: id
					}
					that.Request.request('getMaintainMouldListD', obj, (ret) => {
						console.log(ret.data);

						ret.data.ds.map((item) => {
							item.ApplyForTime = item.ApplyForTime ? item.ApplyForTime.split('T')[0] : ''
							item.BeginTime = formatDateTime(item.BeginTime)
							item.WCTime = formatDateTime(item.WCTime)

							item.Way = (item.Way === 'null') ? null : item.Way;
							const dictMappings = {
								MaintenanceStatus: {
									dictKey: 'MJWXS',
									targetField: 'MaintenanceStatusName'
								},
								Way: {
									dictKey: 'WXFS',
									targetField: 'WayName'
								},
								FResult: {
									dictKey: 'SBWX',
									targetField: 'FResultName'
								},
							};
							that.mapDictNamesForItem(item, dictMappings);

						})
						that.baseFormData = ret.data.ds[0]
						that.addPeriodTypeClick()
						that.$forceUpdate()

					})
				} catch (e) {
					console.log(e)
					this.$utils.hideLoading();
					this.$utils.msg('请求失败请重试')
				}
			},
			// 退出
			leftClick() {
				let routes = getCurrentPages(); //当前页面栈
				let prevPage = routes[routes.length - 2]
				prevPage.$vm.getList()
			}
		}
	}
</script>

<style lang="scss">
	@import "./css/index.scss";


	.content {
		.BottomBox {
			display: flex;
			align-items: center;
			justify-content: flex-end;
			padding: 10px 10px;

			.CancelBtn {
				background-color: #fff;
				color: #51d0d0;
				border: 1px solid #51d0d0;
				min-width: 60px;
			}

			.ComfirmBtn {
				background-color: #51d0d0;
				color: #fff;
				min-width: 60px;
				margin-left: 10px !important;
			}
		}
	}
</style>